package Pantallas;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;

import BusinessDelegate.BDCliente;
import DTO.SucursalVO;
import Exception.CommunicationException;
import Exception.LookUpException;
import Exception.NoExisteException;
import Exception.URLException;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class CrearEmpleado extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6720401688212334136L;
	private JPanel contentPane;
	private JTextField textField_Nombre;
	private JTextField textField_DNI;
	private JTextField textField_Categoria;
	private JTextField textField_Usuario;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					CrearEmpleado frame = new CrearEmpleado();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public CrearEmpleado() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 431, 450);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNombre = new JLabel("Nombre");
		lblNombre.setBounds(58, 48, 105, 14);
		contentPane.add(lblNombre);
		
		JLabel lblDni = new JLabel("DNI");
		lblDni.setBounds(58, 98, 105, 14);
		contentPane.add(lblDni);
		
		JLabel lblNewLabel = new JLabel("Categoria");
		lblNewLabel.setBounds(58, 152, 105, 14);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("Usuario");
		lblNewLabel_1.setBounds(58, 206, 105, 14);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblSucursal = new JLabel("Sucursal");
		lblSucursal.setBounds(58, 259, 105, 14);
		contentPane.add(lblSucursal);
		
		textField_Nombre = new JTextField();
		textField_Nombre.setBounds(173, 45, 158, 20);
		contentPane.add(textField_Nombre);
		textField_Nombre.setColumns(10);
		
		textField_DNI = new JTextField();
		textField_DNI.setBounds(173, 95, 158, 20);
		contentPane.add(textField_DNI);
		textField_DNI.setColumns(10);
		
		textField_Categoria = new JTextField();
		textField_Categoria.setBounds(173, 149, 158, 20);
		contentPane.add(textField_Categoria);
		textField_Categoria.setColumns(10);
		
		textField_Usuario = new JTextField();
		textField_Usuario.setBounds(173, 203, 158, 20);
		contentPane.add(textField_Usuario);
		textField_Usuario.setColumns(10);
		
		JComboBox<String> sucursalesCombo = new JComboBox<String>();
		sucursalesCombo.setBounds(173, 256, 158, 20);
		contentPane.add(sucursalesCombo);
		try {
			ArrayList<SucursalVO> sucursales = BDCliente.getInstancia().buscarSucursales();
			for(SucursalVO s : sucursales)
				sucursalesCombo.addItem(s.getNombre());
		} catch (NoExisteException | URLException | CommunicationException | LookUpException e) {
			e.printStackTrace();
		}
		
		JButton btnAceptar = new JButton("Aceptar");
		btnAceptar.setBounds(58, 336, 89, 23);
		contentPane.add(btnAceptar);
		
		JButton btnCancelar = new JButton("Cancelar");
		btnCancelar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});
		btnCancelar.setBounds(242, 336, 89, 23);
		contentPane.add(btnCancelar);
				
	}
}
